home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / SFLI10.ZIP / SFLI.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-19  |  53.0 KB  |  941 lines

  1. ;    FLI Playing routine                           
  2. ;    Some bugs i assume...but it shows the FLI-file somewhat correctly....
  3. ;    At least i haven't found any errors...the code should be fairly
  4. ;    understandable...and slow...it reads all data from the disk as the 
  5. ;    FLI plays...so if somebody could add XMS support or something...
  6. ;    For details on copyrights and legal stuff see the dox...       
  7. ;    If you wanna contact me for some reason, mail me at shaitan@proxxi.uf.se
  8. ;                                                                               
  9. ;                a SHAi'TAN production                  
  10. ;                      (c) 1996
  11.  
  12.                                                       
  13.     DOSSEG                                        
  14.     IDEAL                                         
  15.     P386                                                        
  16.     LOCALS                                        
  17.                                                                     
  18.         INCLUDE "vga.inc"     
  19.                                     
  20. ;    MemCopy                                                         
  21. ;    Copies vmem variable to video
  22.                                                       
  23. MACRO   MemCopy                                       
  24.                                          
  25.     pusha                                         
  26.                               
  27.                                                       
  28.     mov     ax,fs                                               
  29.     mov     ds,ax                                 
  30.                                                                     
  31.     mov     di,0                                            
  32.     mov     si,OFFSET vmem                        
  33.     mov     ax,0a000h                                  
  34.     mov     es,ax                                               
  35.     mov     cx,64000                              
  36.     rep     movsb                                 
  37.                                                   
  38.     popa                                                        
  39.                                                   
  40. ENDM    MemCopy                                                         
  41.                                                                 
  42.                                                       
  43. STRUC   FLIHead                ; FLI Header Structure
  44.                                       
  45. size    dd      ?                                             
  46. magic   dw      ?                                             
  47. frames  dw      ?                                             
  48. unim    db      8 DUP(?)                                      
  49. speed   dw      ?                                                   
  50. unim2   db      110 dup(?)                                    
  51.                                                 
  52. ENDS    FLIHead                                               
  53.                                       
  54. STRUC   FrameHead                               ; FLI Frame Stucture
  55.                                     
  56. size    dd      ?                                           
  57. magic   dw      ?                                           
  58. chunks  dw      ?                                           
  59. unim    db      8 DUP(?)                                            
  60.                                                 
  61. ENDS    FrameHead                                                       
  62.                                                    
  63. STRUC   ChunkHead                               ; FLI Chunk Structure
  64.                                                 
  65. size    dd      ?                                            
  66. type    dw      ?                                            
  67.                                         
  68. ENDS    ChunkHead                                            
  69.                                                                 
  70.                                                          
  71. FLI_COLOR       EQU     11                      ; The Differnt chunk types
  72. FLI_LC          EQU     12                                        
  73. FLI_BLACK       EQU     13                                          
  74. FLI_BRUN        EQU     15                                                 
  75. FLI_COPY        EQU     16                                          
  76. TailLen         EQU     0080h                   ; Offset of param len byte
  77. CommandTail     EQU     0081h                   ; Offset of parameters
  78. PIC8259         EQU     0020h         
  79. EOI             EQU     0020h        
  80.                                                             
  81.                                                     
  82. SEGMENT _stack PARA STACK 'stack'               ; Stack area...no simplified memory
  83.                                                 ; models here...all done the REAL
  84.         dw      1024 DUP(?)                     ; way...             
  85.                                                                     
  86. ENDS    _stack                                                      
  87.                                                      
  88. SEGMENT data PARA PRIVATE 'data'                                        
  89.                                                  
  90. clhelp  db      "Syntax: SFLI [fliname]",10,13,"(even somebody like you should have understood that...)$"
  91. error   db      "Can't open fli file...$"                    
  92. error2  db      "Error in FLI...$"              ; Different Status and Error messages
  93. endmezz db      35 DUP(' '),"FLI Viewer",10,13,29 DUP(' '),"a SHAi'TAN production",10,13,36 DUP(' '),"(c) 1996",10,13,'$'
  94. Zeropal db      768 DUP(0)                      ; Palettes for the funky fade effects...
  95. MPal    db      786 DUP(63)                                                     
  96. Oldpal  db      768 DUP(?)                                                      
  97. Pal     db      768 DUP(?)                                                      
  98. head    FLIHead <>                                                              
  99. fhead   FrameHead       <>                                                      
  100. chead   ChunkHead       <>                                                      
  101. fname   db      128 DUP (?)                     ; Space for command line params
  102. fhan    dw      ?                               ; FLI File handle    
  103. bytes   dw      ?                               ; Different index vars...
  104. index   dw      ?                                                       
  105. temp    dw      ?                                                       
  106. max     dw      ?                                                   
  107. timer    dw    ?                                                
  108. numParams       DW      ?                       ; Number of parameters   
  109. skip    db      ?                                                       
  110. sizec   db      ?                                                       
  111. char    db      ?                                                       
  112. packs   db      ?                                                       
  113. clocktick       dw      ?                       ; Tick counters for the modified INT 08h routine
  114. videotick    dw    ?                                                                            
  115.                                                                         
  116. ENDS    data                                                            
  117.                                                             
  118. SEGMENT video PARA PRIVATE UNINIT 'data'                                
  119.                                                       
  120. vmem    db      64000 DUP(?)                    ; A video memory size buffer    
  121.                                                     
  122. ENDS    video                                                           
  123.                                              
  124. SEGMENT data2 PARA PRIVATE 'data'                                       
  125.                                                              
  126. buf     db      65535 DUP(?)                    ; A general data buffer         
  127.                                             
  128. ENDS    data2                                                           
  129.                                                       
  130. SEGMENT code PARA PRIVATE 'code'                                            
  131.                                                    
  132.     ASSUME CS:code,DS:data,ES:NOTHING,FS:video,GS:data2,SS:_stack       
  133.                                                    
  134.                                                 
  135. inProgress      DB      0                                                   
  136. OldInt08h       dd      ?                       ; this is called by timer 0 (INT 8)     
  137.                                                                             
  138. ;    Tick                                                            
  139. ;    New INT 08h handler                                             
  140.                                                                         
  141. PROC    Tick                                                                
  142.                                                                             
  143.                                                                             
  144.         cmp     [byte cs:inProgress], 0         ; Check in-progress flag            
  145.         jne     f89                                                     
  146.         inc     [byte cs:inProgress]                                    
  147.                                                                         
  148.         sti                                     ; Allow interrupts to occur     
  149.         push    ax                              ; Save modified registers       
  150.         push    ds                                                      
  151.         push    dx                                                      
  152.                                                                         
  153.         mov     al, EOI                         ; Allow the next timer INT to occur
  154.         out     PIC8259, al                                             
  155.                                                                         
  156.     mov    ax,data                                                 
  157.     mov    ds,ax                                                   
  158.         inc     [clocktick]                     ; Increase the tick counters
  159.         inc    [videotick]                                         
  160.                                                                                      
  161.         cmp     [videotick],9                   ; Check if video tick should occur(approx. 70 times/second)
  162.     jb    checkclock                                                                                
  163.     inc     [timer]
  164.                                                                                       
  165.         mov    [videotick],0                                                         
  166.                                                                                       
  167. checkclock:                                                                           
  168.                                                                                       
  169.         cmp     [clocktick],35                  ; Check if clock tick should occur(approx. 18 times/second)
  170.     jae    f99                                                 
  171.                                                                             
  172.         cli                                     ; Disable interrupts                
  173.         dec     [byte cs:inProgress]            ; Reset in-progress flag            
  174.         pop     dx                              ; Restore saved registers           
  175.         pop     ds                                                          
  176.         pop     ax                                                          
  177.                                                                         
  178.     jmp    f89                                                 
  179.                                                                     
  180. f99:                                                                    
  181.      mov    [clocktick],0                                       
  182.                                                                 
  183.         cli                                     ; Disable interrupts                
  184.         dec     [byte cs:inProgress]            ; Reset in-progress flag            
  185.         pop     dx                              ; Restore saved registers           
  186.         pop     ds                                                          
  187.         pop     ax                                                          
  188.                                                                      
  189.         jmp     [DWORD cs:OldInt08h]            ; Call old INT 08h          
  190.                                                                 
  191. f89:                                                                
  192.                                                                     
  193.     iret                                                        
  194.                                                                         
  195. ENDP    Tick                                                            
  196.                                                                     
  197. ;    Whitespace                                                      
  198. ;    Checks for spaces and tabs                                  
  199.                                                                     
  200. PROC    Whitespace                                                      
  201.         mov     al, [si]                        ; Get character at ds:si
  202.         cmp     al, 020h                          
  203.         je      @@10                                   
  204.         cmp     al, 009h                            
  205.         je      @@10                                   
  206.         cmp     al, 00Dh                             
  207. @@10:                                                               
  208.         ret                                       
  209. ENDP    Whitespace                                                  
  210.                                                                     
  211. ;    GetParams                                                   
  212. ;    Inits the command line parameter buffer                     
  213.                                                                     
  214. PROC    GetParams                                                   
  215.                                                                     
  216.                                                                     
  217.         xor     ch, ch                                                  
  218.         mov     cl, [ds:TailLen]                ; cx = length of parameters 
  219.         inc     cx                              ; Include cr at end         
  220.         mov     si, CommandTail                                         
  221.         mov     di, offset fname        
  222.                                                                     
  223. @@10:                                                               
  224.                                                                     
  225.         call    Whitespace                      ; Skip leading blanks & tabs
  226.         jne     @@20                            ; Jump if not a blank or tab
  227.         inc     si                                                  
  228.         loop    @@10                                                
  229.                                                                     
  230. @@20:                                          
  231.                                         
  232.         push    cx                              ; Save cx for later
  233.         jcxz    @@30                            ; Skip movsb if count = 0
  234.         rep     movsb                   
  235.                                         
  236.                                         
  237. @@30:                                                                   
  238.         push    es                      
  239.         pop     ds                      
  240.         pop     cx                       
  241.         xor     bx, bx                          ; Init parameter count
  242.         jcxz    @@60                            ; Skip loop if length = 0
  243.         mov     si, offset fname        
  244. @@40:                                   
  245.         call    Whitespace                      ; Check for blank, tab, or cr
  246.         jne     @@50                            ; Jump if not a separator
  247.         mov     [byte ptr si], 0                ; Change separator to null
  248.         inc     bx                    
  249. @@50:                                   
  250.         inc     si                      
  251.         loop    @@40                    
  252. @@60:                                   
  253.         mov     [numParams], bx                 ; Save number of parameters
  254.         ret                             
  255.                                         
  256. ENDP    GetParams                       
  257.                                                                         
  258. ;    Sleep                           
  259. ;    Waits for correct timing        
  260.                                                                         
  261. PROC    Sleep    far                                                     
  262.                                                                         
  263. still:                                                                  
  264.                                                                         
  265.     mov    ax,[timer]        
  266.         cmp     ax,[head.speed]                 ; Compare FLI Playing speed
  267.     jb    still                
  268.                                                                 
  269.     mov    [timer],0                                           
  270.                                                                 
  271.     ret                                                         
  272.                                                                 
  273. ENDP    Sleep                                                       
  274.                                                                     
  275. ;    flc                             
  276. ;    Decodes FLI_LC frames           
  277.                                                                         
  278. PROC    flc       far                                                 
  279.                                                              
  280.     mov     [index],0                                               
  281.     mov     [bytes],0                                               
  282.                                                             
  283.     mov     ah,3fh                          ; Read data to buffer   
  284.     mov     bx,[fhan]                                               
  285.     mov     ecx,[chead.size]        
  286.     push    ds                      
  287.     mov    dx,data2                
  288.     mov    ds,dx                   
  289.     mov     dx,OFFSET buf           
  290.     int    21h                     
  291.                                                                 
  292.     pop    ds                      
  293.                                     
  294.     mov    ax,[word buf]            ; Get First modified line
  295.     mov    [temp],ax                                                
  296.                                                                      
  297.     add     [bytes],2                                                
  298.                                                                  
  299.       mov    bp,[bytes]                                               
  300.                                                                        
  301.     mov    ax,[word buf+bp]      
  302.       mov     [max],ax                                                 
  303.                                                                          
  304.     add     [bytes],2                                                
  305.                                                                     
  306.     mov     ax,[max]            ; Get Last modified line
  307.     add     ax,[temp]                                               
  308.     mov     [max],ax                                                
  309.                                                                         
  310. lnextline:                                                              
  311.                                        
  312.     mov     ax,[temp]                                               
  313.     imul    ax,320                                                  
  314.     mov     [index],ax            ; Screen write position
  315.                                                  
  316.     mov    bp,[bytes]                                              
  317.     mov     al,[byte buf+bp]                                           
  318.     mov     [packs],al            ; Get number of packets in this line
  319.                                                                                 
  320.     inc     [bytes]                                                             
  321.                                                                             
  322.     cmp     [packs],0                                                           
  323.     jne     lnextpack
  324.                                                                 
  325.     inc     [temp]                                                  
  326.     mov     ax,[max]                                                
  327.     cmp     ax,[temp]                                               
  328.     je      vcopy                                                   
  329.                                                                 
  330.     jmp     lnextline                                               
  331.                                               
  332. lnextpack:                                                              
  333.                                          
  334.     mov    bp,[bytes]                                              
  335.     mov    al,[byte buf+bp]                                        
  336.     mov     [skip],al            ; Get Skip Count
  337.                                                                     
  338.     inc     [bytes]                                                     
  339.                                           
  340.     mov     al,[skip]                                               
  341.     mov     ah,0                                               
  342.     add     [index],ax                                          
  343.                                        
  344.     mov    bp,[bytes]                                      
  345.     mov    al,[byte buf+bp]                                
  346.     mov     [sizec],al            ; Get Size var
  347.                                                                
  348.     inc     [bytes]                                       
  349.                                                 
  350.     test    [sizec],10000000b                                       
  351.     jnz     lpositive            ; Jump if negative
  352.                                           
  353.     mov     cl,[sizec]                                        
  354.     mov     ch,0                                                    
  355.                                                             
  356.     mov     di,[index]                                              
  357.     add     [index],cx                                              
  358.     mov     ax,fs                                                   
  359.     mov     es,ax                                                   
  360.     mov    bp,[bytes]                                              
  361.     add     [bytes],cx                                                  
  362.     mov     si,gs                                                   
  363.     push    ds                                                      
  364.     mov     ds,si                                             
  365.     mov     si,OFFSET buf                                     
  366.     add    si,bp                                             
  367.     rep     movsb                ; Copy [sizec] byte to video
  368.                                                                     
  369.     pop     ds                                                          
  370.                                                                     
  371.     dec     [packs]                                                     
  372.     cmp     [packs],0                                                   
  373.     jne     lnextpack                                                   
  374.                                                                 
  375.     inc     [temp]                ; Check for last line
  376.     mov     ax,[max]                                                    
  377.     cmp     [temp],ax                                                   
  378.     jne     lnextline                                                   
  379.                                                                     
  380.     jmp     lvcopy                                                      
  381.                                                                             
  382. lpositive:                                                                  
  383.                                                              
  384.     neg     [sizec]                ; ABS(sizec)
  385.                                                      
  386.     mov    bp,[bytes]                                           
  387.     mov    al,[byte buf+bp]                                     
  388.     mov     [char],al            ; Get Char to copy
  389.                                                                  
  390.     inc     [bytes]                                              
  391.                                          
  392.     mov     cl,[sizec]                                              
  393.     mov     ch,0                                              
  394.     mov     di,[index]                                              
  395.     mov     ax,fs                                                   
  396.     mov     es,ax                                              
  397.     mov     al,[char]                                               
  398.     add     [index],cx                                              
  399.     rep     stosb                ; Store [sizec] [char]:s to vidmem
  400.                                                   
  401.     dec     [packs]                                                           
  402.     cmp     [packs],0
  403.     jne     lnextpack
  404.                                      
  405.     inc     [temp]                                                      
  406.     mov     ax,[max]                                            
  407.     cmp     [temp],ax                                           
  408.     jne     lnextline                                           
  409.                                                            
  410.     jmp     lvcopy                                              
  411.                                         
  412. lvcopy:                                                                 
  413.                                         
  414.     call    Sleep                ; Wait for correct timing
  415.                                                                      
  416.     push    ds                                                       
  417.     MemCopy                   ; Copy memory                                                       
  418.     pop     ds                                           
  419.                                              
  420.     ret                                                              
  421.                                               
  422. ENDP    flc                                                              
  423.                                          
  424.                                          
  425. PROC    fbrun   far                                                         
  426.                                          
  427.     mov     [index],0                                                
  428.     mov     [temp],0                                                 
  429.     mov    [bytes],0                                                
  430.                                           
  431.     mov     ah,3fh                          ; Read data to buffer    
  432.     mov     bx,[fhan]                                                
  433.     mov     ecx,[chead.size]                                         
  434.     push    ds                                                       
  435.     mov    dx,data2
  436.     mov    ds,dx                                                    
  437.     mov     dx,OFFSET buf                                            
  438.     int     21h                                                      
  439.     pop    ds                                                       
  440.                                                                      
  441. bnextline:                                      ; Suddenly, aliens force me to                         
  442.                                                 ; stop writing comments...figthing
  443.         mov     ax,[temp]                       ; for my life, i still try to 
  444.         imul    ax,320                          ; put some in....=)
  445.     mov     [index],ax                                              
  446.                                                                     
  447.     mov    bp,[bytes]     
  448.     mov    al,[byte buf+bp]
  449.     mov    [packs],al
  450.     inc    [bytes] 
  451.                                            
  452. bnextpack:                                                                  
  453.                                       
  454.     mov    bp,[bytes]
  455.     mov    al,[byte buf+bp]                                        
  456.     mov    [sizec],al
  457.                                                                     
  458.     inc     [bytes]                                            
  459.                                                                          
  460.     test    [sizec],10000000b                                       
  461.     jz      positive                                                
  462.                                         
  463.     neg     [sizec]                                                 
  464.                      
  465.     mov     cl,[sizec]
  466.     mov     ch,0                                                
  467.                 
  468.     mov    bp,[bytes]
  469.     add    [bytes],cx
  470.     mov     di,[index]                                          
  471.     add     [index],cx                                          
  472.     mov     ax,fs                                                   
  473.     mov     es,ax                                                   
  474.     push    ds                                                      
  475.     mov     si,gs                                                   
  476.     mov     ds,si                                               
  477.     mov     si,OFFSET buf                                           
  478.     add    si,bp                                               
  479.     rep     movsb                                               
  480.                                                                 
  481.     pop     ds                                                          
  482.                                             
  483.     dec     [packs]                                             
  484.     cmp     [packs],0
  485.     jne     bnextpack                                               
  486.                    
  487.     inc     [temp]                                                  
  488.     cmp     [temp],200                                              
  489.     jne     bnextline                                          
  490.                                                                 
  491.     jmp     vcopy    
  492.                                                             
  493. positive:                                                               
  494.                                          
  495.                                                                         
  496.     mov    bp,[bytes]
  497.     mov    al,[byte buf+bp]                                        
  498.     mov    [char],al
  499.                                                                     
  500.     inc    [bytes]                                  
  501.                             
  502.     mov     cl,[sizec]
  503.     mov     ch,0                                                    
  504.     mov     di,[index]                                              
  505.     mov     ax,fs   
  506.     mov     es,ax                                                   
  507.     mov     al,[char]                                               
  508.     add     [index],cx                                         
  509.     rep     stosb                                                   
  510.                                     
  511.     dec     [packs]                                             
  512.     cmp     [packs],0                                               
  513.     jne     bnextpack                                               
  514.                 
  515.     inc     [temp]                                                  
  516.     cmp     [temp],200                                          
  517.     jne     bnextline                                               
  518.                 
  519.     jmp     vcopy                                               
  520.                                                    
  521. vcopy:                          
  522.                 
  523.     Call    Sleep   
  524.                                                                     
  525.     push    ds                                                  
  526.                                                                     
  527.     MemCopy                                                         
  528.                                                                
  529.     pop     ds                                                      
  530.                     
  531.                                           
  532.     ret                                                             
  533.                                         
  534. ENDP    fbrun                                                       
  535.                                         
  536.                                      
  537. PROC    fcolor  far                                                     
  538.                                     
  539.     mov     dx,OFFSET temp                                      
  540.     mov     cx,2                                                        
  541.     mov     ah,3fh          
  542.     mov     bx,[fhan]                                               
  543.     int     21h                                                     
  544.                                                                     
  545.     sub     [word chead.size],ax                                
  546.                                                             
  547.     mov     ah,3fh                          ; Read data to buffer   
  548.     mov     bx,[fhan]                                               
  549.     mov     cx,[word chead.size]                                    
  550.     mov     dx,SEG buf                                           
  551.     push    ds                                                  
  552.     mov     ds,dx                                                   
  553.     mov     dx,OFFSET buf                                           
  554.     int     21h                                                  
  555.     pop     ds                                                      
  556.     sub     [word chead.size],ax                                
  557.                                                
  558.     mov     bp,0    
  559.                                                             
  560. nextpack:                                                                   
  561.                     
  562.     mov     bh,0                                                    
  563.     mov     bl,[byte buf+bp]                                        
  564.     inc     bp                                                      
  565.     mov     ch,0                                                
  566.     mov     cl,[byte buf+bp]                                        
  567.     inc     bp                                                      
  568.     cmp     cx,0                                                    
  569.     jne     colok                                                   
  570.     mov     cx,256        
  571.                                                         
  572. colok:                                                                  
  573.     mov     ax,cx                                                   
  574.     shl     cx,1    
  575.     add     cx,ax                                                   
  576.                                                             
  577.     mov     dx,3c8h                                                 
  578.     mov     al,bl   
  579.     out     dx,al                                               
  580.                                                                     
  581.     push    ds              
  582.     mov     ax,gs                                                   
  583.     mov     ds,ax                                                   
  584.     mov     si,OFFSET buf                                           
  585.     add     si,bp                                               
  586.     add     bp,cx                                                   
  587.                                                                 
  588.     WaitRetrace                                                     
  589.                 
  590.     mov     dx,3c9h 
  591.     rep     outsb                                               
  592.                                                                     
  593.     pop     ds
  594.     
  595.     dec     [temp]                                                  
  596.     cmp     [temp],0                                            
  597.     jne     nextpack                                                
  598.             
  599.                                                             
  600.     ret                                                                 
  601.                         
  602. ENDP    fcolor                                                          
  603.                                                                  
  604. Start:                                                                  
  605.                                 
  606.     mov    ax,data
  607.     mov    es,ax
  608.     call    GetParams
  609.     mov     ax,data                         ; Init all segments     
  610.     mov     ds,ax                                                   
  611.     mov     ax,data2                                                
  612.     mov     gs,ax                                                   
  613.     mov     ax,video                                                
  614.     mov     fs,ax                                                   
  615.                                                                     
  616.     push    ds                                                      
  617.                                                                     
  618.     mov    [timer],0                                               
  619.         mov     ax, 3508h                       ; Get interrupt 08 vector       
  620.         int     21h                               
  621.         mov     [word OldInt08h+2], es          ; Save SEG value
  622.         mov     [word OldInt08h], bx            ; Save OFFSET value
  623.                                                                             
  624.         push    ds                                
  625.         mov     ax, 2508h                       ; Set interrupt 08 vector       
  626.         push    cs                           
  627.         pop     ds                      
  628.         mov     dx, offset tick                 ; DS:DX -> new routine
  629.         int     21h                             ; Set new interrupt vector      
  630.         pop     ds                              ; Restore ds                    
  631.                                                                         
  632.     mov    al,00110110b
  633.     out    43h,al                                                  
  634.     mov    ax,1894
  635.     out    40h,al 
  636.     mov    al,ah
  637.     out    40h,al                                                  
  638.                                                                         
  639.     cmp    [numParams],1                                           
  640.     jae    parok                                                   
  641.                                                                     
  642.     mov     ah,09h                          ; Write error string                                                                          
  643.     mov     dx,OFFSET clhelp                                        
  644.     int     21h
  645.     
  646.     jmp    ending
  647.                             
  648. parok:                     
  649.                                                                     
  650.     mov     ah,3dh                          ; Open file        
  651.     mov     al,2                                               
  652.     mov     dx,OFFSET fname                                         
  653.     xor     cl,cl                                              
  654.     int     21h                                                 
  655.     jnc     openok                                                  
  656.                                              
  657.     mov     ah,09h                          ; Write error string                                                                          
  658.     mov     dx,OFFSET error                                         
  659.     int     21h                                                     
  660.                                     
  661.     jmp     ending                                                  
  662.                                        
  663. openok:                                                                 
  664.                                     
  665.     mov     [fhan],ax                       ; Save handle           
  666.                                      
  667.     mov     ah,3fh                                                  
  668.     mov     bx,[fhan]                                               
  669.                                                                     
  670.     mov     cx,128                                                  
  671.     mov     dx,OFFSET head                  ; Read FLI header       
  672.     int     21h                                                     
  673.                                     
  674.     cmp     [head.magic],0af11h             ; Check if FLI          
  675.     je      fliok                                                   
  676.                                         
  677.     mov     ah,09h                          ; Write error string                                                                          
  678.     mov     dx,OFFSET error2                                           
  679.     int     21h                                                     
  680.                                            
  681.     jmp     ending                                                  
  682.                                     
  683. fliok:                                                                  
  684.                                     
  685.     HideCursor                                                  
  686.                                                                 
  687. ;    dec    [head.frames]                                           
  688.                                                                     
  689.     pusha                                                           
  690.                                                                     
  691.     mov ax,SEG Oldpal                                               
  692.     mov es,ax                                                       
  693.     mov di,OFFSET Oldpal                                            
  694.                                                                         
  695.     SavePal                                                                                                                               
  696.     
  697.     mov di,OFFSET Pal                                               
  698.                                                                     
  699.     SavePal                                                         
  700.                                                         
  701.     mov cx,64                                                       
  702. Down:                                                               
  703.     mov ax,SEG Pal                                              
  704.     mov es,ax                                                       
  705.     mov di,OFFSET Pal
  706.               
  707.     mov ax,SEG ZeroPal                                              
  708.     mov ds,ax
  709.     mov si,OFFSET ZeroPal
  710.     
  711.     FadeOut                                                     
  712.     
  713.     mov ax,SEG Pal
  714.     mov ds,ax                                                           
  715.     mov si,OFFSET Pal                                                                                                                     
  716.     
  717.     SetPal                                                          
  718.                                                                     
  719.     loop Down                                                       
  720.                                                         
  721.     popa                                                            
  722.                                                                 
  723.     VGA                                     ; Switch to VGA mode 13h
  724.                                         
  725. nextframe:                                                          
  726.                                       
  727.     cmp     [head.frames],0                                         
  728.     je      endoffli                                            
  729.     dec     [head.frames]                                       
  730.                                     
  731.     mov     ah,3fh                                              
  732.     mov     bx,[fhan]                                           
  733.     mov     cx,16                                               
  734.     mov     dx,OFFSET fhead                 ; Read frame header         
  735.     int     21h                                                                                                                           
  736.                                     
  737. nextchunk:                                                              
  738.                                         
  739.     cmp     [fhead.chunks],0                                        
  740.     je      nextframe                                               
  741.     dec     [fhead.chunks]                                          
  742.                                     
  743.     mov     ah,3fh                                              
  744.     mov     bx,[fhan]                                               
  745.     mov     cx,6                                                
  746.     mov     dx,OFFSET chead                 ; Read chunk header 
  747.     int     21h                                                     
  748.                                     
  749.     mov     eax,[chead.size]                                    
  750.     sub     eax,6                                               
  751.     mov     [chead.size],eax                                    
  752.                                     
  753.     cmp     [chead.type],FLI_COLOR                              
  754.     je      color                                                       
  755.     cmp     [chead.type],FLI_LC                                                                                                           
  756.     je      lc                                                  
  757.     cmp     [chead.type],FLI_BLACK                                  
  758.     je      black                                                   
  759.     cmp     [chead.type],FLI_BRUN                                   
  760.     je      brun                                                    
  761.     cmp     [chead.type],FLI_COPY                                   
  762.     je      copy                                                
  763.                                        
  764.     Text25                                                          
  765.                                       
  766.     mov     ah,09h                          ; Write error string
  767.     mov     dx,OFFSET error2                                           
  768.     int     21h                                                    
  769.                                        
  770.     jmp     ending                                              
  771.                                        
  772. color:                   
  773.              
  774.     call    fcolor                                                      
  775.     jmp     nextchunk                                                                                                                     
  776.                
  777. lc:                                                                     
  778.                                                              
  779.     call    flc                                                     
  780.     jmp     nextchunk                                          
  781.                                              
  782. black:                                                                      
  783.                                                                                                               
  784.     call    Sleep
  785.                            
  786.     WaitRetrace                                                     
  787.                                         
  788.     ClrVGA                                                          
  789.                                    
  790.     mov     ax,0                                               
  791.     mov     bx,fs                                               
  792.     mov     es,bx                                                   
  793.     mov     di,0                                               
  794.     mov     cx,32000                                                    
  795.     rep     stosw                                               
  796.     jmp     nextchunk                                               
  797.                                                         
  798. brun:                                                              
  799.                                                                
  800.     call    fbrun                                              
  801.     jmp     nextchunk                                               
  802.                                                         
  803. copy:                    
  804.              
  805.     mov     ah,3fh                                              
  806.     mov     bx,[fhan]                                           
  807.     mov     cx,64000                                                
  808.     push    ds                                                  
  809.     mov     dx,fs                                                   
  810.     mov     ds,dx                                                                                                                         
  811.     mov     dx,OFFSET vmem                  ; Read buffer           
  812.     int     21h            
  813.                                                                     
  814.     call    Sleep                                                       
  815.                                                                  
  816.     WaitRetrace  
  817.                                                                  
  818.     MemCopy                                                         
  819.                                                                
  820.     pop     ds                                                      
  821.     jmp     nextchunk                                               
  822.                                                                 
  823.                                                                 
  824. endoffli:                                                               
  825.                                                                 
  826.     mov    ah,1     
  827.     int     16h                                                     
  828.     jz    endoffli 
  829.     mov    ah,0     
  830.     int    16h                                                                                                                           
  831.                          
  832.     mov ax,SEG Pal                                              
  833.     mov es,ax                                                       
  834.     mov di,OFFSET Pal                                                   
  835.                      
  836.     SavePal          
  837.                                                          
  838.     mov cx,64                                                   
  839. Down2:                                                                  
  840.          mov ax,SEG Pal                                              
  841.     mov es,ax                                                       
  842.     mov di,OFFSET Pal                                           
  843.                                                                 
  844.     mov ax,SEG ZeroPal                                          
  845.     mov ds,ax                                                   
  846.     mov si,OFFSET ZeroPal                                       
  847.                                                                     
  848.     FadeOut                                                     
  849.                                                                 
  850.     mov ax,SEG Pal                                                                                                                        
  851.     mov ds,ax                                                   
  852.     mov si,OFFSET Pal                                           
  853.                                                                     
  854.     SetPal                                                              
  855.                                                                 
  856.     loop Down2                   
  857.                                                         
  858.     Text25                                                      
  859.                                                                     
  860.     HideCursor                   
  861.                                                   
  862.     mov ax,SEG ZeroPal                                              
  863.     mov ds,ax                                                       
  864.     mov si,OFFSET ZeroPal                                           
  865.                                                                         
  866.     SetPal                                                          
  867.                                                                         
  868.     mov     ah,09h                                                  
  869.     mov     dx,OFFSET endmezz                                       
  870.     int     21h                                                                                                                           
  871.                                                                         
  872.     mov cx,64                                                       
  873. @@U:                                                                    
  874.     mov ax,SEG Pal                                                      
  875.     mov es,ax                                                       
  876.     mov di,OFFSET Pal                                               
  877.                                                                         
  878.     mov ax,SEG MPal                                                 
  879.     mov ds,ax                                                       
  880.     mov si,OFFSET MPal                                              
  881.                                         
  882.     FadeIn                                                          
  883.                                                                         
  884.     mov ax,SEG Pal                                                  
  885.     mov ds,ax                                                       
  886.     mov si,OFFSET Pal                                               
  887.                                                                         
  888.     SetPal                                                          
  889.                                                                     
  890.     loop @@U                                                                                                                              
  891.                                                                         
  892.     mov cx,64                                                       
  893. @@p:                                                                    
  894.     mov ax,SEG Pal                                                      
  895.     mov es,ax                                                       
  896.     mov di,OFFSET Pal                                               
  897.                                                                         
  898.     mov ax,SEG Oldpal                                               
  899.     mov ds,ax                                                       
  900.     mov si,OFFSET OldPal                                            
  901.                                             
  902.     FadeOut                                                         
  903.                                                                         
  904.     mov ax,SEG Pal                                                  
  905.     mov ds,ax                                                       
  906.     mov si,OFFSET Pal                                               
  907.                                                                         
  908.     SetPal                                                          
  909.                                                                     
  910.     loop @@p                                                                                                                              
  911.                                                                         
  912.     ShowCursor                                                      
  913.                                                                         
  914.                                                                             
  915. ending:                        
  916.                    
  917.     mov    al,00110110b                                            
  918.     out    43h,al
  919.     mov    ax,65535
  920.     out    40h,al                                                  
  921.     mov    al,ah
  922.     out    40h,al
  923.  
  924.         push    ds                              ; Save ds, changed below
  925.         mov     ax, 2508h                       ; Set interrupt 08 vector
  926.         mov     dx, [word OldInt08h]            ; Get saved offset value
  927.         mov     ds, [word OldInt08h+2]          ; Get saved segment value
  928.         int     21h
  929.         pop     ds                              ; Restore ds
  930.  
  931.     mov     ax,4c00h
  932.     int     21h     
  933.             
  934. ENDS    code            
  935.                                                                             
  936. END     Start
  937.  
  938. ;    Hmm...it seems that the comments faded away towards the end...
  939. ;    who cares anyway...apart from me in 20 days and anybody else
  940. ;    reading this code...:)...
  941.